
HOME=`pwd`
BUILD=$HOME/build
SRC=$HOME/src
RUN=$HOME/run
PROTO=$HOME/protocal
#TOOLS_DB=$HOME/run/tools/db


function Help()
{
    echo "Usage: AllMake.sh command "
    echo "  commands are:"
    #echo "  installdep                安装开发环境(需要sudo授权)"
    echo "  proto                  转化协议"
    #echo "  gensql                 gensql"
    echo "  debug                  debug模式构建执行文件"
    echo "  clean                  清理中间文件和执行文件"
    #echo "  release                release  SVRNAME"
    #echo "  verbose                verbose  SVRNAME [note : mode[debug]]"
    #echo "  conf"
    #echo "  create                 server_prefix"
}

function InstallDep()
{
    echo "install dep"
}

function Proto()
{
    if (cd $PROTO);
    then
        cd $PROTO;
    else
        return
    fi

    if (cd comm);
    then
        cd comm
        chmod +x convert.sh
        ./convert.sh
        cd ..
    else
        return
    fi
    
    if (cd cs);
    then
        cd cs
        chmod +x convert.sh
        ./convert.sh
        cd ..
    else
        return
    fi

}

function Make()
{
    if (cd $BUILD);
    then                                                                                                                                              
        cd $BUILD
    else
        mkdir $BUILD
        cd $BUILD
    fi
    
    
    cmake $SRC -DCMAKE_BUILD_TYPE=DEBUG 
    make 
}


case $1 in
    installdep)
        InstallDep $#
        ;;

    proto)
        Proto $#
        ;;
    debug)
        Make $#
        ;;
    clean)
        if (cd $BUILD);
        then
            cd $BUILD
            make clean
        fi
        ;;  
    *)
        Help
        ;;
esac
